package com.zmj.config;


import com.google.code.kaptcha.Producer;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/*@Configuration
public class KaptchaConfig  {

    @Bean
    public Producer producer(){

        DefaultKaptcha producer =new DefaultKaptcha();
        Properties properties =new Properties();

        Config config =new Config(properties);

        return  producer;
    }
}*/
@Configuration   //@Configuration  等价于spring配置文件
public class KaptchaConfig {

    @Bean //等价于   <bean id="producer" class="xxxx">
    public Producer producer(){
        DefaultKaptcha producer = new DefaultKaptcha();
        Properties properties = new Properties();
        //设置验证码的长度
        // properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_LENGTH,"1");
        //properties.setProperty(Constants.KAPTCHA_BORDER,"none");

        Config config = new Config(properties);

        producer.setConfig(config);
        return  producer;
    }

}

